/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.cip.esymons.general.be;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;


/**
 *
 * @author lizardo
 */
@Entity
@Table(name = "gen_distrito")
@NamedQueries({@NamedQuery(name = "Distrito.findAll", query = "SELECT d FROM Distrito d"), @NamedQuery(name = "Distrito.findByDisCodigo", query = "SELECT d FROM Distrito d WHERE d.disCodigo = :disCodigo"), @NamedQuery(name = "Distrito.findByDisNombre", query = "SELECT d FROM Distrito d WHERE d.disNombre = :disNombre")})
public class Distrito implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "dis_codigo")
    private Integer disCodigo;
    @Basic(optional = false)
    @Column(name = "dis_nombre")
    private String disNombre;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "fkDisCodigo", fetch = FetchType.LAZY)
    private List<Zona> zonaList;
    @JoinColumn(name = "pro_codigo", referencedColumnName = "pro_codigo")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Provincia proCodigo;
    @OneToMany(mappedBy = "disCodigo", fetch = FetchType.LAZY)
    private List<DireccionPersona> direccionPersonaList;

    public Distrito() {
    }

    public Distrito(Integer disCodigo) {
        this.disCodigo = disCodigo;
    }

    public Distrito(Integer disCodigo, String disNombre) {
        this.disCodigo = disCodigo;
        this.disNombre = disNombre;
    }

    public Integer getDisCodigo() {
        return disCodigo;
    }

    public void setDisCodigo(Integer disCodigo) {
        this.disCodigo = disCodigo;
    }

    public String getDisNombre() {
        return disNombre;
    }

    public void setDisNombre(String disNombre) {
        this.disNombre = disNombre;
    }

    public List<Zona> getZonaList() {
        return zonaList;
    }

    public void setZonaList(List<Zona> zonaList) {
        this.zonaList = zonaList;
    }

    public Provincia getProCodigo() {
        return proCodigo;
    }

    public void setProCodigo(Provincia proCodigo) {
        this.proCodigo = proCodigo;
    }

    public List<DireccionPersona> getDireccionPersonaList() {
        return direccionPersonaList;
    }

    public void setDireccionPersonaList(List<DireccionPersona> direccionPersonaList) {
        this.direccionPersonaList = direccionPersonaList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (disCodigo != null ? disCodigo.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Distrito)) {
            return false;
        }
        Distrito other = (Distrito) object;
        if ((this.disCodigo == null && other.disCodigo != null) || (this.disCodigo != null && !this.disCodigo.equals(other.disCodigo))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.cip.esymons.general.bc.Distrito[disCodigo=" + disCodigo + "]";
    }

}
